
; Test cases for external bindings

; Note: The debug packages are currently all 32bit only, if this gets changed, this value
;   must be changed accordingly
;
(define bytes-per-cell 4)

(define-test-suite external-tests "external-tests" (lambda ()

  ;; Just minimal testing to see if the opcodes are handled correctly
  ;; For some real testing, run the FFI tests
  ;;
  (bool-test find-undefined-imported-bindings (vector? (find-undefined-imported-bindings)) "find-undefined-imported-bindings" #t)

  (newline)
  (write-string "lookup-shared-binding")
  (lookup-shared-binding "not_defined" #t)
  (newline)    
    
  (write-string "undefine-shared-binding")
  (undefine-shared-binding "not_defined_anyway" #t)
  (newline)
  
  ; do this only when running under scheme, where these opcodes are just faked anyway
  (if (not (is-real-vm?))
    (begin
      (write-string "call-external-value, call-external-value-2")
      (newline)
      (call-external-value (make-byte-vector bytes-per-cell 0) "some_name" 3)
      (call-external-value-2 (make-byte-vector bytes-per-cell 0) "some_name" 1 2 3 4)
      
      (write-string "vm-extension")
      (newline)
      (vm-extension 0 (false))))
    
  ; Cannot properly test this here, use the FFI tests instead:
  ; return-from-callback 
    
  ))